home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/env python
-
- #
- # This file is part of OpenVIP (http://openvip.sourceforge.net)
- #
- # Copyright (C) 2002-2003
- # Michal Dvorak, Jiri Sedlar, Antonin Slavik, Vaclav Slavik, Jozef Smizansky
- #
- # This program is licensed under GNU General Public License version 2;
- # see file COPYING in the top level directory for details.
- #
- # $Id: fileinfo.py,v 1.4 2003/05/24 22:17:22 vaclavslavik Exp $
- #
-
- #
- # Display file's metadata information.
- # Implemented using OpenVIP input plugins.
- #
-
- import openvip, sys
-
- if len(sys.argv) < 2:
- sys.stderr.write("""
- Usage: %s filename [filename ...]
-
- where 'filename' may be either name of audio or video file or name of
- OpenVIP network format file (*.openvip, *.xml)
- """ % sys.argv[0])
-
-
- def printFileInfo(lib, filename):
- splitted = filename.split(':')
- if len(splitted) == 2 and (splitted[0].endswith('.xml') or
- splitted[0].endswith('.openvip')):
- print 'OpenVIP network file: %s' % filename
- task = lib.load_network_file(splitted[0])
- i = lib.get_task_file_info(task, splitted[1])
- else:
- print 'Multimedia file: %s' % filename
- i = lib.get_file_info(filename)
-
- if i == None:
- sys.stderr.write('Error when reading %s\n' % filename)
- return
- for v in i.video_streams:
- seconds = float(v.length)/v.fps
- print ' video stream "%s"' % v.name
- print ' width: %i' % v.width
- print ' height: %i' % v.height
- print ' fps: %f' % v.fps
- print ' aspect ratio: %f' % v.aspect
- print ' length: %i frames (%.1f sec)' % (v.length, seconds)
- for a in i.audio_streams:
- seconds = float(a.length)/a.sample_rate
- print ' audio stream "%s"' % a.name
- print ' sample rate: %i Hz' % a.sample_rate
- print ' channels: %i' % a.channels
- print ' length: %i samples (%.1f sec)' % (a.length, seconds)
-
-
- lib = openvip.Library()
-
- for f in sys.argv[1:]:
- printFileInfo(lib, f)
-